package com.persondemo.videoappliction.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.persondemo.videoappliction.R;
import com.persondemo.videoappliction.bean.PingLunBean;
import com.persondemo.videoappliction.utils.ImageLoaderUtil;

import java.util.List;

/**
 * Created by Administrator on 2018/4/24.
 */

public class PingLunAdapter extends BaseQuickAdapter<PingLunBean.DataBean, BaseViewHolder> {
    private Context mcontext;

    public PingLunAdapter(@Nullable List<PingLunBean.DataBean> data, Context context) {
        super(R.layout.item_pinlun, data);
        this.mcontext = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, PingLunBean.DataBean item) {
        if (TextUtils.isEmpty(item.getAvatar())){
            // 加载应用资源
            int resource = R.mipmap.user_head;
            ImageLoaderUtil.LoadImagelarge(mcontext,resource, helper.getView(R.id.pinglun_img));
        }else {
            ImageLoaderUtil.LoadImagelarge(mcontext, item.getAvatar(), helper.getView(R.id.pinglun_img));
        }

        helper.setText(R.id.pinglun_name, item.getUsername());
        helper.setText(R.id.pinglun_comment, item.getContent());
        helper.setText(R.id.pinglun_zan, item.getPraise()+"");
        helper.addOnClickListener(R.id.pinglun_dianzan);
    }
}
